

from selenium.webdriver.common.by import By

from Base.base_page import WebBasePage


class CommentsPade(WebBasePage):
    """
    评论
    """
    def __init__(self):
        super().__init__()
        # 1.点击评论按钮
        self.comments_button = (By.XPATH,'/html/body/div[1]/div[1]/section/div/div/div/div[1]/div/div/div[1]/div/div[1]/div/div[2]/div/div[5]/div[2]/div[2]/div[3]/div/div/div/div/div[2]/img')
        # 2.点击输入文本框、3.输入评论
        self.comments_text = (By.XPATH,'//*[@placeholder="说点什么..."]')
        # 4.点击取消
        self.comments_cancel = (By.XPATH,'/html/body/div[1]/div[1]/section/div/div/div/div[1]/div/div/div[1]/div/div[2]/div[1]/div[2]/div[1]/div/div[1]')
        # 5.再次点击输入文本框# 6.输入评论
        # 7.点击发送
        self.comments_send = (By.XPATH,'/html/body/div[1]/div[1]/section/div/div/div/div[1]/div/div/div[1]/div/div[2]/div[1]/div[2]/div[1]/div/button/span')
        # 8.鼠标滑动评论区查看其他评论
        # 9.关闭评论区
        self.comments_close = (By.XPATH,'/html/body/div[1]/div[1]/section/div/div/div/div[1]/div/div/div[1]/div/div[2]/div[2]/img')

    # 点击
    def comments_to_button(self,one_text,two_text):
        self.click_element(self.find_element(self.comments_button))
        self.click_element(self.find_element(self.comments_text))
        self.input_text(self.find_element(self.comments_text),one_text)
        self.click_element(self.find_element(self.comments_cancel))
        self.click_element(self.find_element(self.comments_text))
        self.input_text(self.find_element(self.comments_text),two_text)
        self.click_element(self.find_element(self.comments_send))
    def comments_to_close(self):
        self.click_element(self.find_element(self.comments_close))

